package demo2;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 涛
 * Date: 2023-10-23
 * Time: 15:02
 */
public class Test {
    public static void func() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<?> c1 = Class.forName("demo2.TestEnum");

        Constructor constructor = c1.getDeclaredConstructor(String.class, int.class, int.class, String.class);

        constructor.setAccessible(true);

        TestEnum testEnum = (TestEnum) constructor.newInstance("白色", 9, 6, "棕色");

    }

    public static void main(String[] args) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
        func();
    }
}
